#include "Balls.h"

Balls::Balls(){
	for(int i =0;i<100;i++){
		xOffsets[i] = rand()%9-5.5;
	}
}

void Balls::draw(int offsetFromDistanceTravelled){
	//draw Obstacles
	GLfloat whiteSpecularMaterial[] = {1.0, 1.0, 1.0}; //set the material to white
	GLfloat mShininess[] = {64}; //set the shininess of the material

	glPushMatrix();
	glColor3f(1,1,1);
	for (int i=offsetFromDistanceTravelled; i<5+offsetFromDistanceTravelled; i++)
	{
		glPushMatrix();
		position[i-offsetFromDistanceTravelled][0] = xOffsets[i%100]*2+3;
		position[i-offsetFromDistanceTravelled][1] = 1;
		position[i-offsetFromDistanceTravelled][2] = 20-i*100;
		glTranslatef(
			position[i-offsetFromDistanceTravelled][0],
			position[i-offsetFromDistanceTravelled][1],
			position[i-offsetFromDistanceTravelled][2]);

		glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mShininess);
		glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,whiteSpecularMaterial);
		glutSolidSphere(1,32,32);

		glPopMatrix();
	}
	glPopMatrix();
}